<template>
	<view >
		<!--轮播-->
		<view style=" margin:5px 5px;margin-bottom: 10px; border-radius: 5px; overflow: hidden">
			<u-swiper :list="banner" keyName="image" indicator indicatorMode="dot" imgMode="aspectFill" circular
				:height="120">
			</u-swiper>
		</view>

		<!--核心功能-->
		<view >
			 <view style="margin: 5px 10px;background-color: #FFF;border-radius: 5px;">
			 	<u-grid :border="false" col="4">
			 		<u-grid-item @click="handleModule('unpay')" :custom-style="'padding:20px 15px;position:relative'" >
			 			<u-image src="/static/icon/unpay.png" width="30" height="30"></u-image>
			 			<text class="grid-text">待付款</text>
						<view style=" position:absolute; right: 20px; top:15px">
							<u-badge type="error" :value="orderInfo.unpay"></u-badge>
						</view>
			 		</u-grid-item>
			 		 
					<u-grid-item @click="handleModule('unsend')" :custom-style="'padding:20px 15px;position:relative'" >
						<u-image src="/static/icon/unsend.png" width="30" height="30"></u-image>
						<text class="grid-text">待发货</text>
						<view style=" position:absolute; right: 20px; top:15px">
							<u-badge type="error"  :value="orderInfo.unsend"></u-badge>
						</view>
						
					</u-grid-item>
					
					<u-grid-item @click="handleModule('done')" :custom-style="'padding:20px 15px;position:relative'">
						<u-image src="/static/icon/sent.png" width="30" height="30"></u-image>
						<text class="grid-text">已发货</text>
						<view style=" position:absolute; right: 20px; top:15px">
							<u-badge type="error"  :value="orderInfo.send"></u-badge>
						</view>
					</u-grid-item>
					
					<u-grid-item @click="handleModule('cancel')" :custom-style="'padding:20px 15px;position:relative'" >
						<u-image src="/static/icon/unpay.png" width="30" height="30"></u-image>
						<text class="grid-text">退换货</text>
						<view style=" position:absolute; right: 20px; top:15px" >
							<u-badge type="error"   :value="orderInfo.cancel"></u-badge>
						</view>
					</u-grid-item>
			 	</u-grid>
			 </view>
			
		</view>
		
	
		
		
	</view>
</template>

<script>
	import { post } from '@/utils/request';
	export default {
		data() {
			return {
				banner: [{
						image: 'https://aidianducdn.520diandu.com//storage/uploads/banner/202502/20250222101929_44032_16.png',
						link: ''
					},
					{
						image: 'https://aidianducdn.520diandu.com//storage/uploads/banner/202506/20250618153251_71699_7.jpg',
						link: ''
					},
					{
						image: 'https://aidianducdn.520diandu.com//storage/uploads/banner/202503/20250319154231_44750_7.jpg',
						link: ''
					}
				],
				orderInfo:{
					unpay:12,
					unsend:0,
					send:33,
					cancel:2
				}
			}
		},
		onShow() {
			this.loadHomeData();
		},
		onLoad() {
           if(uni.getStorageSync("token")==""){
			   uni.navigateTo({
			   	url:"/pages/login/index"
			   })
		   }
		},
		onPullDownRefresh() {
			//下拉刷新，获取最新订单信息
			this.loadHomeData();
		},
		methods: {
			loadHomeData(){
				post("/home/index").then(res=>{
					if(res.statusCode==200 && res.data.code==1){
						if(res.statusCode==200 && res.data.code){
							this.orderInfo=res.data.data;
						}
						uni.stopPullDownRefresh();
					}else{
						uni.stopPullDownRefresh();
					}
				})
			},
			handleModule(type){
					uni.navigateTo({
						url:"/pages/buy/index?otype="+type
					})

			}
		}
	}
</script>

<style scoped>
	.grid-text{
		margin-top: 5px;
		font-size: 12px;
	}

</style>